/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019.
 * Description: check the permission and capability of syslog message
 * Author: chenjialong
 * Create: 2018-9-11
 */

#include <linux/printk.h>
#include <linux/syslog.h>
#include <linux/capability.h>
#include <linux/errno.h>

#ifdef CONFIG_RTOS

/*
 * Function     : check_msg_restrict
 * Description  : For security reasons, the permissions of the interfaces
 *                provided by rtos must not larger than 644, and must
 *                check the capabilities at open time. Rtos provide a
 *                temporary sysctl parameter to open/close the capabilities
 *                check.
 * Return       : Upon successful return 0, otherwise return negative error code.
 */
int check_msg_restrict(void)
{
	if ((dmesg_restrict && capable(CAP_SYSLOG)) || (dmesg_restrict == 0))
		return 0;
	return -EPERM;
}

#endif
